<?php

/**
 * tools
 * @author:Cloud<190296465@vip.qq.com>
 * @copyright:Copyright 2018 Cloud
 * @create:2018-12-25
 * @modify:2018-12-25
 */

namespace Admin\Controller;

class ToolsController extends CommonController
{

    function eCode()
    {
        $content = I('get.content');
        $size = I('get.size');
        if ($content && $size) {
            $value = $content ? $content : "http://www.icxps.cn";
            $outfile = false; //默认为否，不生成文件，只将二维码图片返回，否则需要给出存放生成二维码图片的路径
            $errorCorrectionLevel = "L"; //L-7% M-15% Q-25% H-30% 不同的参数表示二维码可被覆盖的区域百分比。
            $matrixPointSize = $size ? $size : 7; //控制生成图片的大小
            $margin = 2; //控制生成二维码的空白区域大小
            ob_end_clean();
            $QRcode = new \Common\Org\Qrcode\QRcode();
            $QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize, $margin);
            return;
        }
        $this->display();
    }

    function mailTo()
    {
        $title = I('post.title');
        $content = I('post.content');
        $email = I('post.email');
        if ($title && $content && $email) {
            $res = \Common\Org\Util::SendMail($email, 's', $title, $content);
            if ($res === true) {
                $this->ajaxReturn(array('html' => '发送成功'));
            } else {
                $this->ajaxReturn(array('html' => $res));
            }
            return;
        }
        $this->display();
    }

}

?>